// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Permissive License.
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
// All other rights reserved.

using System;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Globalization;
using AjaxControlToolkit;

[assembly: System.Web.UI.WebResource("GridControl.TreePaneBehavior.js", "text/javascript")]

namespace GridControl
{
    /// <summary>
    /// Given a proper hierarchy of elements, turn it into an Accordion
    /// </summary>
    [Designer("GridControl.TreePaneDesigner, GridControl")]
    [ToolboxItem(false)]
    [ClientScriptResource("GridControl.TreePaneBehavior", "GridControl.TreePaneBehavior.js")]
    [RequiredScript(typeof(YUI), 1)]
    [RequiredScript(typeof(ext_yui_adapter), 2)]
    [RequiredScript(typeof(YUI_ext), 3)]
    [RequiredScript(typeof(TreeExtension), 4)]
    [TargetControlType(typeof(Control))]
    public class TreePaneExtender : ExtenderControlBase
    {
        /// <summary>
        /// Enable ClientState
        /// </summary>
        public TreePaneExtender()
        {
            EnableClientState = false;
        }
        /// <summary>
        /// true to enable animated expand/collapse
        /// </summary>
        [ExtenderControlProperty]
        public bool animate
        {
            get
            {
                return GetPropertyValue<bool>("animate",true);
            }
            set
            {
                SetPropertyValue<bool>("animate", value);
            }
        }
        /// <summary>
        /// true to register this container with ScrollManager
        /// </summary>
        [ExtenderControlProperty]
        public bool containerScroll
        {
            get
            {
                return GetPropertyValue<bool>("containerScroll", true);
            }
            set
            {
                SetPropertyValue<bool>("containerScroll", value);
            }
        }
        /// <summary>
        /// True if the tree should only allow append drops (use for trees which are sorted)
        /// </summary>
        [ExtenderControlProperty]
        public bool ddAppendOnly
        {
            get
            {
                return GetPropertyValue<bool>("ddAppendOnly", false);
            }
            set
            {
                SetPropertyValue<bool>("ddAppendOnly", value);
            }
        }
        /// <summary>
        /// The DD group this TreePanel belongs to
        /// </summary>
        [ExtenderControlProperty]
        public string ddGroup
        {
            get
            {
                return GetPropertyValue<string>("ddGroup", "TreeDD");
            }
            set
            {
                SetPropertyValue<string>("ddGroup", value);
            }
        }

       
        /// <summary>
        /// true to enable drag and drop
        /// </summary>
        [ExtenderControlProperty]
        public bool enableDD
        {
            get
            {
                return GetPropertyValue<bool>("enableDD", false);
            }
            set
            {
                SetPropertyValue<bool>("enableDD", value);
            }
        }
        /// <summary>
        /// true to enable just drag
        /// </summary>
        [ExtenderControlProperty]
        public bool enableDrag
        {
            get
            {
                return GetPropertyValue<bool>("enableDrag", false);
            }
            set
            {
                SetPropertyValue<bool>("enableDrag", value);
            }
        }
        /// <summary>
        /// true to enable just drop
        /// </summary>
        [ExtenderControlProperty]
        public bool enableDrop
        {
            get
            {
                return GetPropertyValue<bool>("enableDrop", false);
            }
            set
            {
                SetPropertyValue<bool>("enableDrop", value);
            }
        }
        /// <summary>
        /// false to disable tree lines (defaults to true)
        /// </summary>
        [ExtenderControlProperty]
        public bool lines
        {
            get
            {
                return GetPropertyValue<bool>("lines", true);
            }
            set
            {
                SetPropertyValue<bool>("lines", value);
            }
        }
        /// <summary>
        /// false to hide the root node (defaults to true)
        /// </summary>
        [ExtenderControlProperty]
        public bool rootVisible
        {
            get
            {
                return GetPropertyValue<bool>("rootVisible", true);
            }
            set
            {
                SetPropertyValue<bool>("rootVisible", value);
            }
        }
        /// <summary>
        /// Name of the ppage that will load ajax nodes
        /// </summary>
        [ExtenderControlProperty]
        public string Loader
        {
            get
            {
                return GetPropertyValue<string>("Loader", "");
            }
            set
            {
                SetPropertyValue<string>("Loader", value);
            }
        }
        /// <summary>
        /// Initial tree nodes
        /// </summary>
        [ExtenderControlProperty]
        public string TreeNodes
        {
            get
            {
                return GetPropertyValue<string>("TreeNodes", "");
            }
            set
            {
                SetPropertyValue<string>("TreeNodes", value);
            }

        }
        /// <summary>
        /// Gets or sets the web service method.
        /// </summary>
        /// <value>The web service method.</value>
        [ExtenderControlProperty]
        public string WebServiceMethod
        {
            get
            {
                return GetPropertyValue<string>("WebServiceMethod", null);
            }
            set
            {
                SetPropertyValue<string>("WebServiceMethod", value);
            }
        }
        /// <summary>
        /// Gets or sets the web service path.
        /// </summary>
        /// <value>The web service path.</value>
        [ExtenderControlProperty]
        public string WebServicePath
        {
            get
            {
                return GetPropertyValue<string>("WebServicePath", null);
            }
            set
            {
                SetPropertyValue<string>("WebServicePath", value);
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="T:TreePaneExtender"/> is editable.
        /// </summary>
        /// <value><c>true</c> if editable; otherwise, <c>false</c>.</value>
        [ExtenderControlProperty]
        public bool Editable
        {
            get
            {
                return GetPropertyValue<bool>("Editable", false);
            }
            set
            {
                SetPropertyValue<bool>("Editable", value);
            }
        }
        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="T:TreePaneExtender"/> is editable.
        /// </summary>
        /// <value><c>true</c> if editable; otherwise, <c>false</c>.</value>
        [ExtenderControlProperty]
        public bool autoPostBack
        {
            get
            {
                return GetPropertyValue<bool>("autoPostBack", false);
            }
            set
            {
                SetPropertyValue<bool>("autoPostBack", value);
            }
        }
        /// <summary>
        /// Indicates if the Tree should be rendered with a checkbox
        /// </summary>
        [ExtenderControlProperty]
        public bool CheckBoxTree
        {
            get
            {
                return GetPropertyValue<bool>("CheckBoxTree", false);
            }
            set
            {
                SetPropertyValue<bool>("CheckBoxTree", value);
            }
        }
        /// <summary>
        /// The json string for the tree context menu
        /// </summary>
        [ExtenderControlProperty]
        public string ContextMenu
        {
            get
            {
                return GetPropertyValue<string>("ContextMenu", string.Empty);
            }
            set
            {
                SetPropertyValue<string>("ContextMenu", value);
            }

        }
        
    }
}
